package com.gitee.deeround.jdbchelper.core.dialect;

import com.gitee.deeround.jdbchelper.exception.DbException;
import com.gitee.deeround.jdbchelper.out.DataType;

public abstract class BaseDialectCore implements DialectCore {
    @Override
    public String resolveDataType(DataType dataType, int length, int scale) {
        switch (dataType) {
            case String:
                return getDataType().get(dataType) + "(" + length + ")";
            case Char:
                return getDataType().get(dataType) + "(" + length + ")";
            case Date:
                return getDataType().get(dataType);
            case Clob:
                return getDataType().get(dataType);
            case Blob:
                return getDataType().get(dataType);
            case Integer:
                return getDataType().get(dataType) + "(" + length + ")";
            case Decimal:
                return getDataType().get(dataType) + "(" + length + "," + scale + ")";
            case Object:
                throw new DbException("未知数据类型");
            default:
                throw new DbException("Unexpected value: " + dataType);
        }
    }
}
